package com.gozap.jdk;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import org.junit.Test;

public class JdkStudy {

	@Test
	public void studyJdk() {
		TreeMap<Long, String> treeMap = new TreeMap<Long, String>();
		treeMap.put(1L, "1");

		HashMap<String, String> hashMap = new HashMap<String, String>();
		hashMap.put("1", "1");

		ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<String>(100);
		queue.add("1");

		ArrayList<String> arrayList = new ArrayList<String>();
		arrayList.add("1");

		AtomicInteger atomicInteger = new AtomicInteger();
		atomicInteger.get();

		ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
		readWriteLock.isFair();

		CopyOnWriteArrayList<String> copyOnWriteArrayList = new CopyOnWriteArrayList<String>();
		copyOnWriteArrayList.add("1");

		ConcurrentHashMap<String, String> concurrentHashMap = new ConcurrentHashMap<String, String>();
		concurrentHashMap.put("1", "2");
	}

	@Test
	public void studyArrayBlockQueue() throws Exception {
		ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<String>(2);
		queue.put("1");
		queue.put("2");
		// queue.put("3");
		System.out.println("over");
	}

	@SuppressWarnings("deprecation")
	@Test
	public void testAge() throws Exception {
		String birthStr = "1990-01-02";
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Date birthDate = format.parse(birthStr);
		System.out.println(birthDate);
		System.out.println(birthDate.getTime());
		birthDate.setYear(91);
		System.out.println(birthDate);
		System.out.println(birthDate.getTime());

	}

}
